<?php

use console\db\Migration;
use yii\helpers\ArrayHelper;
use yii\helpers\Console;

/**
 * 初始化类型数据
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m200110_000120_d_danger_levels extends Migration {

    /**
     * @inheritdoc
     */
    public $tableName = '{{%danger_level}}';

    /**
     * @inheritdoc
     */
    public function safeUp() {
        if (!$this->isExistsTable($this->tableName)) {
            return false;
        }
        $this->truncateTable($this->tableName);
        $this->compact = true;
        $data = [
            '一般',
            '较大',
            '重大',
        ];
        foreach ($data as $name) {
            $this->insert($this->tableName, [
                'name' => $name,
                'status' => 10,
                'created_at' => time(),
                'updated_at' => time(),
            ]);
        }
    }

}
